package com.tjbklx1.pattern.factory.demo2;

public class ConCreator extends Creator {

	@SuppressWarnings("unchecked")
	public <T extends Product> T createProduct(Class<T> c) {
		Product p = null;
		try {
			p = (Product) Class.forName(c.getName()).newInstance();
		} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
			System.out.println("Create product error.");
			e.printStackTrace();
		}
		return (T) p;
	}
}
